Summary
};
use core::dependency::SerializedDependency;
-use util::{CargoResult, graph, Config};
+use util::{CargoResult, graph};
use serialize::{Encoder,Encodable};
-use core::source::{SourceId, SourceSet, Source};
+use core::source::{SourceId, Source};
// TODO: Is manifest_path a relic?
#[deriving(Clone)]
ret.push_all(self.manifest.get_source_ids());
ret
}
-
- pub fn get_fingerprint(&self, config: &mut Config) -> CargoResult<String> {
- let mut sources = self.get_source_ids();
- // Sort the sources just to make sure we have a consistent fingerprint.
- sources.sort_by(|a, b| {
- let a = (&a.kind, a.location.to_string());
- let b = (&b.kind, b.location.to_string());
- a.cmp(&b)
- });
- let sources = sources.iter().map(|source_id| {
- source_id.load(config)
- }).collect::<Vec<_>>();
- SourceSet::new(sources).fingerprint(self)
- }
}
impl Show for Package {
use core::{Package, Target};
use util;
use util::hex::short_hash;
-use util::{CargoResult, Fresh, Dirty, Freshness};
+use util::{CargoResult, Fresh, Dirty, Freshness, Config};
use super::job::Job;
use super::context::Context;
fn is_fresh(dep: &Package, loc: &Path, cx: &mut Context, targets: &[&Target])
-> CargoResult<(bool, String)> {
- let new_pkg_fingerprint = format!("{}{}", cx.rustc_version,
- try!(dep.get_fingerprint(cx.config)));
+ let dep_fingerprint = try!(get_fingerprint(dep, cx.config));
+ let new_pkg_fingerprint = format!("{}{}", cx.rustc_version, dep_fingerprint);
let new_fingerprint = fingerprint(new_pkg_fingerprint, hash_targets(targets));
let hasher = SipHasher::new_with_keys(0,0);
util::to_hex(hasher.hash(&(package, profiles)))
}
+
+fn get_fingerprint(pkg: &Package, config: &mut Config) -> CargoResult<String> {
+ let source_id = pkg.get_package_id().get_source_id();
+ let source = source_id.load(config);
+ source.fingerprint(pkg)
+}
use std::io::File;
+use std::path;
use support::{ProjectBuilder, ResultTest, project, execs, main_file, paths};
use support::{cargo_dir};
execs().with_stdout("hello world\n"));
})
+test!(override_git_dep {
+ let p = project("foo");
+ let root = p.root().clone();
+ let p = p
+ .file(".cargo/config", format!(r#"
+ paths = ['{}/baz']
+ "#, root.display()))
+ .file("Cargo.toml", r#"
+ [package]
+
+ name = "foo"
+ version = "0.5.0"
+ authors = ["wycats@example.com"]
+
+ [dependencies.bar]
+ path = "bar"
+ "#)
+ .file("src/main.rs", "extern crate bar; fn main() {}")
+ .file("bar/Cargo.toml", r#"
+ [package]
+
+ name = "bar"
+ version = "0.5.0"
+ authors = ["wycats@example.com"]
+
+ [dependencies.baz]
+ git = 'git://example.com/path/to/nowhere'
+ "#)
+ .file("bar/src/lib.rs", "extern crate baz;")
+ .file("baz/Cargo.toml", r#"
+ [package]
+
+ name = "baz"
+ version = "0.5.0"
+ authors = ["wycats@example.com"]
+ "#)
+ .file("baz/src/lib.rs", "");
+
+ assert_that(p.cargo_process("cargo-build"),
+ execs()
+ .with_stdout(format!("{compiling} baz v0.5.0 (file:{dir}{sep}baz)\n\
+ {compiling} bar v0.5.0 (file:{dir})\n\
+ {compiling} foo v0.5.0 (file:{dir})\n",
+ compiling = COMPILING, dir = root.display(),
+ sep = path::SEP))
+ .with_stderr(""));
+
+ assert_that(&p.bin("foo"), existing_file());
+
+ assert_that(
+ cargo::util::process(p.bin("foo")),
+ execs().with_stdout(""));
+})
+
test!(cargo_compile_git_dep_branch {
let project = project("foo");
let git_project = git_repo("dep1", |project| {
[dev-dependencies.baz]
- version = "0.5.0"
- path = "baz"
+ git = "git://example.com/path/to/nowhere"
[[lib]]
pub fn gimme() -> &'static str {
"zoidberg"
}
- "#)
- .file("bar/baz/Cargo.toml", r#"
- [project]
-
- name = "baz"
- version = "0.5.0"
- authors = ["wycats@example.com"]
-
- [[lib]]
-
- name = "baz"
- "#)
- .file("bar/baz/src/baz.rs", r#"
- pub fn gimme() -> &'static str {
- "nope"
- }
"#);
assert_that(p.cargo_process("cargo-build"),
-use std::os;
-use std::path;
-
-use support::{project, execs, basic_bin_manifest};
-use support::{RUNNING, COMPILING};
-use hamcrest::{assert_that, existing_file};
-use cargo::util::process;
+use support::{project, execs};
+use hamcrest::assert_that;
fn setup() {
}